﻿using System;
using System.Net;
using System.Windows;
using SimpleJson;

namespace MetroEventbrite.External.Eventbrite
{
    public class EBOrganizer
    {
        public static EBOrganizer Load(string json)
        {
            var result = new EBOrganizer();

            JsonObject jsonObj;
            try
            {

                jsonObj = (JsonObject)SimpleJson.SimpleJson.DeserializeObject(json);
            }
            catch (Exception ex)
            {
                return result;
            }
            return Load(jsonObj);
        }

        private static EBOrganizer Load(JsonObject jsonObj)
        {
            var result = new EBOrganizer();
            if (jsonObj.ContainsKey("id"))
            {
                result.OrganizerId = jsonObj["id"].ToString();
            }
            if (jsonObj.ContainsKey("name"))
            {
                result.OrganizerName = jsonObj["name"].ToString();
            }
            if (jsonObj.ContainsKey("description"))
            {
                result.Description = jsonObj["description"].ToString();
            }
            if (jsonObj.ContainsKey("url"))
            {
                result.Url = jsonObj["url"].ToString();
            }
            return Load(jsonObj);
        }

        public string OrganizerId { get; set; }

        public string OrganizerName { get; set; }

        public string Description { get; set; }

        public string Url { get; set; }
    }
}
